/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package co.infinum.goldfinger.crypto;

import co.infinum.goldfinger.Goldfinger;
import ohos.biometrics.authentication.BiometricAuthentication;

/**
 * A reprint module handles communication with a specific fingerprint api.
 * 指纹api调用方法
 * <p/>
 * Implement this interface to add a new api to Reprint, then pass an instance of this interface to
 */
public interface ReprintModule {

    void init(BiometricAuthentication.AuthType type, BiometricAuthentication.SecureLevel level);

    /**
     * Return true if a fingerprint reader of this type exists on the current device.
     * <p/>
     * Don't call this method directly. Register an instance of this module with Reprint, then call
     * <p>
     * <p>
     * 硬件是否支持
     *
     * @return 类型
     */
    int isHardwarePresent();

    /**
     * Start a fingerprint authentication request.
     * <p/>
     * Don't call this method directly. Register an instance of this module with Reprint, then call
     * {@linkReprint#authenticate(AuthenticationListener)}
     *
     * @param mBiometricAuthentication
     * @param listener
     * @param restartPredicate
     *                                 A signal that can cancel the authentication request.A listener that will be notified of the authentication status.     If the predicate returns true, the module should ensure the sensor
     *                                 is still running, and should not call any methods on the listener.
     *                                 If the predicate returns false, the module should ensure the sensor
     *                                 is not running before calling {@linkAuthenticationListener#onFailure(AuthenticationFailureReason,
     *                                 boolean, CharSequence, int, int)}.
     */
    void authenticate(BiometricAuthentication mBiometricAuthentication, Goldfinger.Callback listener, Goldfinger.RestartPredicate restartPredicate);

    void authenticate(BiometricAuthentication mBiometricAuthentication, Goldfinger.Callback listener, Goldfinger.RestartPredicate restartPredicate, String key, String value);

    int cancelAuthentication();

    /**
     * ;
     * A tag uniquely identifying this class. It must be the same for all instances of each class,
     * and each class's tag must be unique among registered modules.
     *
     * @return 类型
     */
    int tag();
}
